#include "guimaterials.h"
#include "globals.h"
#include "managegame.h"
#include "enemy.h"

static int g_seed = 0;
int randO()
{
	return g_seed = ((g_seed * 1664525) + 1013904223) & 0x7fffffff;
}

void GUI_spawnEntity()
{
	int id = 0;
//	g_console->Print("Mah button! He pressed Mah button!\n");
	// TODO instead of making a new random base object, that is never referenced by anything (memory leak!), add this base object to a list (GameMap.mobs?), and make the game object an AI object...
	point size = g_app.getMap()->getSize(),
		tilesize = g_app.getMap()->getTileSize();
	int w = (int)((size.x-1)*tilesize.x);
	int h = (int)((size.y-1)*tilesize.y);
	int index = Graphics::Engine()->AddAsset("Resources\\art\\servoskull.bmp", color(255, 0, 255));
	Enemy * servoSkullMob = new Enemy(point(randO()%w,randO()%h), index);
	servoSkullMob->setSpeed(10);
	point centerOfMap(size.x*tilesize.x/2, size.y*tilesize.y/2);
	point center = servoSkullMob->getLoc();
	center.add(tilesize.quotient(2));
	point diff = centerOfMap.difference(center);
	diff.setLength(servoSkullMob->Speed());
	servoSkullMob->setVelocity(diff);

	g_app.getMap()->getMobs()->add(servoSkullMob);
	g_app.getGraphics()->AddObject(servoSkullMob,index,0);
	char buffer[256];
	sprintf_s(buffer, sizeof(buffer), "added @ %d, %d\n",
		servoSkullMob->getLoc().x, servoSkullMob->getLoc().y);
	g_console->Print(buffer);
}


bool CheckTest()
{
	return true;
	//Need to make it work.
};
void ExecuteTest()
{
	int x = 25;

};
